package com.spzx.manager.controller;

import com.spzx.manager.service.FileUploadService;
import com.spzx.model.vo.common.Result;
import com.spzx.model.vo.common.ResultCodeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * 文件处理接口层
 * Project: spzx-parent
 * Package: com.spzx.manager.controller
 * Version: 1.0
 * <p>
 * Created by  wangjiaxin  on 2024/2/20 22:42
 */
@RestController
@RequestMapping("/admin/system")
public class FileUploadController {
    @Autowired
    private FileUploadService fileUploadService;

    /**
     * 文件上传
     *
     * @param multipartFile
     * @return
     */
    @PostMapping(value = "/fileUpload")
    public Result<String> fileUploadService(@RequestParam(value = "file") MultipartFile multipartFile) {
        //获取上传文件
        String fileUrl = fileUploadService.fileUpload(multipartFile);
        return Result.build(fileUrl, ResultCodeEnum.SUCCESS);
    }
}
